<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="icon iconfont icon-jifen"></i>查看动态详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-form ref="form" :model="data" label-width="150px" @submit.native.prevent>
                <el-form-item label="动态分类：">
                    <span>{{data.type | typeText}}</span>
                </el-form-item>
                <el-form-item label="标题：">
                    <p v-html="data.title"></p>
                </el-form-item>
                <el-form-item label="封面图：">
                    <p><img :src="data.head_img" style="width:360px;height:180px"/></p>
                </el-form-item>
                <el-form-item label="发布时间：">
                    <p v-html="data.create_time"></p>
                </el-form-item>
                <el-form-item label="浏览数：">
                    <p >{{data.read_num}}</p>
                </el-form-item>
                <el-form-item label="来源：">
                    <p >{{data.source}}</p>
                </el-form-item>
                <el-form-item label="关键词：" v-if="keywords.length>0">
                    <el-tag v-for="item in keywords" :key="item">{{item}}</el-tag>
                </el-form-item>
                <el-form-item label="描述：" style="width:1000px;height:aotu;padding:15px 15px;">
                    <p v-html="data.content"></p>
                </el-form-item>
                <el-form-item>
                    <!-- <el-button type="primary" @click="onAddGoods">确认发布</el-button> -->
                    <el-button  @click="returnList">返回列表</el-button>
                    
                </el-form-item>
            </el-form>
            
        </div>
        
    </div>
</template>
<script>
import { getFenzhanActivityDetail } from "@/api/branch/activity";
export default {
    name:'activityDetail',
    data (){
        return{
            data:{},
             keywords:[],
        }
    },
    created (){
        // console.log(this.$route.query.id)
        this.getNews();
    },
    filters:{
        typeText:function(value){
            var x="评析";
            switch (value) { 
                case 1:x="企业动态"; 
                break; 
                case 2:x="本地新闻"; 
                break; 
                case 3:x="协会动态"; 
                break; 
                case 4:x="政策动态"; 
                break; 
                case 5:x="本地人物"; 
                break; 
                case 6:x="企业访谈"; 
                break; 
            }
            return x;
        }
    },
    methods:{
        getNews (){
            if(this.$route.query.id && this.$route.query.id!=""){
                //要查看详情的对象类型：1活动、2动态、3心情、4求购、5供应、6二手
                getFenzhanActivityDetail(2,this.$route.query.id).then(response=>{
                    // console.log(response);
                    if(response.code==200){
                        //获取数据
                        var data = response.data;
                        try{
                            this.keywords= JSON.parse(data.keywords);
                              //如果第一个元素为空 删除
                            if(this.keywords[0] == ''){
                                  this.keywords.shift();
                            }
                        }
                        catch(e){
                            data.keywords =[];
                        }
                        
                        // console.log(data);
                        this.data = response.data;
                        //console.log(this.data);
                    }else{
                        this.$notify.error({
                            title: '查询失败',
                            duration:2000,
                            message: '失败原因：'+response.data.msg
                        });
                    }
                })
                
            }else{
                this.$message.error('获取ID失败');
            }
        },
        returnList(){
            this.$router.push('/branch/dynamic');
        },
    }
}
</script>
<style lang="stylus" scoped>
    
</style>


